package com.hankol.community.adapter

import com.baselibrary.bean.FriendListBean
import com.baselibrary.extension.checkNotNull
import com.baselibrary.extension.checkValue
import com.baselibrary.utils.GlideUtils
import com.baselibrary.view.VipHeardImgView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.hankol.community.R

/**
 * @author: 关忆北、
 * @date: 2022/4/1
 * @Des：选择好友适配器
 */
class SelectFriendAdapter : BaseQuickAdapter<FriendListBean, BaseViewHolder>(R.layout.item_friendlist) {
    var lastLetter = ""
    var mHashMap: HashMap<String, Int> = hashMapOf()
    override fun convert(helper: BaseViewHolder, item: FriendListBean) {
        helper.setIsRecyclable(false)
        helper
                .setGone(R.id.tv_friendItem_group, item.letter.checkNotNull() && lastLetter != item.letter.checkValue())
                .setText(R.id.tv_friendItem_group, item.letter.checkValue())
                .setText(R.id.tv_friendItem_name, item.name.checkValue())
                .setImageResource(R.id.iv_friendItem_check, if (item.isSelected) R.drawable.ic_friendlist_true_check else R.drawable.ic_friendlist_false_check)
        helper.getView<VipHeardImgView>(R.id.circle_friendItem_head).setData(item.icon.checkValue(), item.isFans == 1)
        if (lastLetter != item.letter.checkValue()) {
            mHashMap[item.letter.checkValue()] = helper.adapterPosition
        }
        lastLetter = item.letter.checkValue()
    }

}